package servlet.admin.permission;

import entity.Modular;
import entity.Permission;
import service.PermissionService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet( name = "AdminPermissionServlet")
public class AdminPermissionServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String characterID=request.getParameter("characterID");
        PermissionService service=new PermissionService();
        List<Modular> list1=service.modularList();//所有的权力
        List<Modular> list2=service.modularsByCharactersID(Integer.parseInt(characterID));//该角色的权利

        request.setAttribute("list1",list1);
        request.setAttribute("list2",list2);
        request.setAttribute("characterID", characterID);
        request.getServletContext().getRequestDispatcher("/admin/permissionIsGet.jsp").forward(request, response);
    }


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
